package edu.faytechcc.csc.gui.search.details;

import edu.faytechcc.csc.gui.search.SearchFrame;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

/**
 * Displays the details of an anime or manga from the SearchFrame parameter in
 * the constructor.
 *
 * @author Stephanie Mckenzie and Jasmin Pastari
 */
public class DetailsPanel extends JPanel
{

    private TitlePanel titles;
    private ImgGenerasPanel imgSugg;
    private JTextArea descriptionTextArea;
    private JScrollPane areaScrollPane;

    /**
     * Constructor for the DetailsPanel class that accepts a SearchFrame.
     *
     * @param search
     */
    public DetailsPanel(SearchFrame search)
    {
        this.setLayout(new BorderLayout());

        // Sets Strings to the related String variables in the SearchFrame
        // accepted in the constructor.
        String engTitle = search.getEngTitle();
        String japTitle = search.getJapTitle();
        String description = search.getDescription();
        String numVol = search.getNumVol();
        String genera = search.getGenera();
        String artist = search.getArtist();
        String photo = search.getPhoto();
        // Adds the information through panels and a text area
        titles = new TitlePanel(engTitle, japTitle, numVol, artist);
        descriptionTextArea = new JTextArea(7, 30);
        descriptionTextArea.append(description);
        descriptionTextArea.setLineWrap(true);
        // ineditable text area, but can still be highlighted
        descriptionTextArea.setEditable(false);
        areaScrollPane = new JScrollPane(descriptionTextArea);
        imgSugg = new ImgGenerasPanel(photo, genera);

        this.add(titles, BorderLayout.NORTH);
        this.add(areaScrollPane, BorderLayout.WEST);
        this.add(imgSugg, BorderLayout.EAST);
    }
}
